/*
 * @Author: 刘岩 15136056318@163.com
 * @Date: 2023-11-05 14:41:04
 * @LastEditors: LiuYan 15136056318@163.com
 * @LastEditTime: 2023-11-30 10:30:02
 * @FilePath: \react-template_pc\src\components\router-guard\index.tsx
 * @Description:
 */
import { useRoute } from '@/hooks'
import user from '@/stores/User'
import { Navigate } from 'react-router-dom'
const RouterGuard = (props: { children: JSX.Element }) => {
  const route = useRoute(true)
  document.title = route.meta.title || ''
  if (user.token) return <>{props.children}</>
  return (
    <>
      <Navigate to="/login"></Navigate>
      {props.children}
    </>
  )
}
export default RouterGuard
